app.controller('GetElequanlistCtrl', function($scope,$http,$state,$location,$localStorage,$window,$interval) {
	$scope.namedata = $localStorage.cur_user.uname;
	$scope.mmData = $localStorage.layers_info;
	$scope.b = {};					
	$scope.getlist = function(){
		
		if($scope.b.school_name!=''&&$scope.b.school_name!=null&&$scope.b.school_name!=undefined){
			$scope.currentPage = 1;//初始当前页
	        $scope.maxSize = 3;//最多显示3页其他的用···代替
	        $scope.c = {};
	        if($scope.b.layer_name.indexOf('所有层')>0){
	        	$scope.c.layer_name = "所有层";
	        	$scope.c.campus_building_id = $scope.b.layer_name.split("+")[1];
	        	$scope.c.layer_id = '';
	        }else{
	        	$scope.c.layer_name = $scope.b.layer_name.split('+')[0];
	        	$scope.c.layer_id = $scope.b.layer_name.split('+')[2];
	        	$scope.c.campus_building_id = $scope.b.layer_name.split('+')[1];
	        }
	        $http.post(
	            $scope.app.backendurl+"tbl-electricity/view-all",
	            {    
	                'page':$scope.currentPage,  
	                'school_name':$scope.b.school_name,
	                'school_id':$scope.b.buildingtype.split('+')[1],
	                'key':$scope.b.key,	               	
	                'campus_building_id':$scope.c.campus_building_id,
	                'building_name':$scope.b.building_name,
	                'building_type':$scope.b.buildingtype.split('+')[0],
	                'layer_id':$scope.c.layer_id,
	                'layer_name':$scope.c.layer_name,
	                'token':$localStorage.token                  

	            }
	          ).success(function (data) {
	            console.log(data);
	            if(data.code==0&&data.msg=="读取成功"){             
	              $scope.aaData = data.data.list;
	              $scope.totalItems = data.data.page.totalCount;          
	            }
	            if(data.code==20001&&data.msg=='请先登录'){
	              $location.path('access.signin');
	            }  

	        $scope.pageChanged = function(){
	        	console.log($scope.currentPage)
	        	 $http.post(
		            $scope.app.backendurl+"tbl-electricity/view-all",
		            {    
		                'page':$scope.currentPage,  
		                'school_name':$scope.b.school_name,
		                'school_id':$scope.b.buildingtype.split('+')[1],
		                'key':$scope.b.key,	               	
		                'campus_building_id':$scope.c.campus_building_id,
		                'building_name':$scope.b.building_name,
		                'building_type':$scope.b.buildingtype.split('+')[0],
		                'layer_id':$scope.c.layer_id,
		                'layer_name':$scope.c.layer_name,
		                'token':$localStorage.token               

		            }
		          ).success(function (data) {
		          	console.log(data);
		          	if(data.code==0&&data.msg=="读取成功"){             
		              $scope.aaData = data.data.list;	                    
		            }
		            if(data.code==20001&&data.msg=='请先登录'){
		              $location.path('access.signin');
		            }  
		          }).error(function(data){

	        	 })
	        }    
	        }).error(function(data){
	          console.log(data);
	        })
		}	
		
				       
    }

    $interval($scope.getlist,60000);	
	            

			   

	
		

	
});